package avicit.bdp.dms.dss.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.dms.prm.dto.TagDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import avicit.platform6.core.properties.PlatformConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * 数据资源表实体
 *
 */
@ApiModel(value = "DataResourceDTO", description = "数据资源表")
@Table(name = "bdp_dss_data_resource")
public class DataResourceDTO extends BaseDTO {

    /**
     * 主键
     *
     */
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "主键")
    @Column(name = "id")
    @Id
    @javax.persistence.Id
    private String id;

    /**
     * 资源名称
     *
     */
    @LogField
    @ApiModelProperty(value = "资源名称")
    @FieldRemark(column = "name", field = "name", name = "资源名称")
    @Column(name = "name")
    private String name;

    /**
     * 发布类型(0-数据1-API接口)
     *
     */
    @LogField
    @ApiModelProperty(value = "发布类型")
    @FieldRemark(column = "releaseType", field = "releaseType", name = "发布类型")
    @Column(name = "release_type")
    private Integer releaseType;

    /**
     * 所属分类
     *
     */
    @LogField
    @ApiModelProperty(value = "所属分类")
    @FieldRemark(column = "typeId", field = "typeId", name = "所属分类")
    @Column(name = "type_id")
    private String typeId;

    /**
     * 所属数据空间
     *
     */
    //@LogField
    @ApiModelProperty(value = "所属数据空间")
    //@FieldRemark(column = "projectId", field = "projectId", name = "所属数据空间")
    @Column(name = "project_id")
    private String projectId;

    /**
     * 状态 0-未发布 1-已发布 2-已撤回
     *
     */
    //@LogField
    @ApiModelProperty(value = "状态 0-未发布 1-已发布 2-已撤回")
    //@FieldRemark(column = "status", field = "status", name = "状态 0-未发布 1-已发布 2-已撤回")
    @Column(name = "status")
    private Integer status;

    /**
     * 类型 0-数据表 1-文件
     *
     */
    @LogField
    @ApiModelProperty(value = "类型 0-数据表 1-文件")
    @FieldRemark(column = "type", field = "type", name = "类型 0-数据表 1-文件")
    @Column(name = "type")
    private Integer type;

    /**
     * 数据权限 0-停用 1-启用
     *
     */
    //@LogField
    @ApiModelProperty(value = "数据权限 0-停用 1-启用")
    //@FieldRemark(column = "dataAuthority", field = "dataAuthority", name = "数据权限 0-停用 1-启用")
    @Column(name = "data_authority")
    private Integer dataAuthority;

    /**
     * 数据表id; 文件资源Id
     *
     */
    @LogField
    @ApiModelProperty(value = "数据表id; 文件资源Id")
    @FieldRemark(column = "tableId", field = "tableId", name = "数据表id; 文件资源Id")
    @Column(name = "table_id")
    private String tableId;

    /**
     * 表名
     *
     */
    @LogField
    @ApiModelProperty(value = "表名")
    @FieldRemark(column = "tableName", field = "tableName", name = "表名")
    @Column(name = "table_name")
    private String tableName;

    /**
     * 字段json
     [{
     "name": "姓名",
     "code":"name",
     "type":"varchar",
     "param": 0
     }]
     *
     */
    //@LogField
    @ApiModelProperty(value = "字段json")
    //@FieldRemark(column = "columnInfo", field = "columnInfo", name = "字段json")
    @Column(name = "column_info")
    private String columnInfo;

    /**
     * 排序json
     [{
     "name": "id",
     "order": 0 //正序
     },{
     "name": "name",
     "order": 1 //倒序
     }]
     *
     */
    @LogField
    @ApiModelProperty(value = "排序json")
    @FieldRemark(column = "orderInfo", field = "orderInfo", name = "排序json")
    @Column(name = "order_info")
    private String orderInfo;

    /**
     * sql过滤
     *
     */
    @LogField
    @ApiModelProperty(value = "sql过滤")
    @FieldRemark(column = "sqlFilter", field = "sqlFilter", name = "sql过滤")
    @Column(name = "sql_filter")
    private String sqlFilter;

    /**
     * api地址
     *
     */
    @LogField
    @ApiModelProperty(value = "api地址")
    @FieldRemark(column = "apiAddress", field = "apiAddress", name = "api地址")
    @Column(name = "api_address")
    private String apiAddress;

    /**
     * 请求方式
     *
     */
    @LogField
    @ApiModelProperty(value = "请求方式")
    @FieldRemark(column = "requestMethod", field = "requestMethod", name = "请求方式")
    @Column(name = "request_method")
    private String requestMethod;

    /**
     * 备注
     *
     */
    @LogField
    @ApiModelProperty(value = "备注")
    @FieldRemark(column = "remark", field = "remark", name = "备注")
    @Column(name = "remark")
    private String remark;

    @LogField
    @ApiModelProperty(value = "查看次数")
    @FieldRemark(column = "viewCount", field = "viewCount", name = "查看次数")
    @Column(name = "view_count")
    private Long viewCount;

    @ApiModelProperty(value = "数据标签")
    @Transient
    private String tagName;

    @ApiModelProperty(value = "所属空间")
    @Transient
    private String projectName;

    @ApiModelProperty(value = "服务分类")
    @Transient
    private String typeName;

    @ApiModelProperty(value = "发布类型")
    @Transient
    private String releaseTypeString;

    @ApiModelProperty(value = "资源类型")
    @Transient
    private String typeString;

    @ApiModelProperty(value = "状态")
    @Transient
    private String statusString;

    @ApiModelProperty(value = "创建人")
    @Transient
    private String createUser;

    @ApiModelProperty(value = "审核状态")
    @Transient
    private Integer auditStatus;

    @ApiModelProperty(value = "columnInfoDtoList")
    @Transient
    private List<ColumnInfoDto> columnInfoDtoList;

    @ApiModelProperty(value = "orderInfoDtoList")
    @Transient
    private List<OrderInfoDto> orderInfoDtoList;

    @ApiModelProperty(value = "tagList")
    @Transient
    private List<TagDTO> tagList;

    @ApiModelProperty(value = "subscribeDTO")
    @Transient
    private DssSubscribeDTO subscribeDTO;

    public Integer getAuditStatus() {
        return auditStatus;
    }

    public void setAuditStatus(Integer auditStatus) {
        this.auditStatus = auditStatus;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getReleaseType() {
        return releaseType;
    }

    public void setReleaseType(Integer releaseType) {
        this.releaseType = releaseType;
    }

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getDataAuthority() {
        return dataAuthority;
    }

    public void setDataAuthority(Integer dataAuthority) {
        this.dataAuthority = dataAuthority;
    }

    public String getTableId() {
        return tableId;
    }

    public void setTableId(String tableId) {
        this.tableId = tableId;
    }

    public String getColumnInfo() {
        return columnInfo;
    }

    public void setColumnInfo(String columnInfo) {
        this.columnInfo = columnInfo;
    }

    public String getOrderInfo() {
        return orderInfo;
    }

    public void setOrderInfo(String orderInfo) {
        this.orderInfo = orderInfo;
    }

    public String getSqlFilter() {
        return sqlFilter;
    }

    public void setSqlFilter(String sqlFilter) {
        this.sqlFilter = sqlFilter;
    }

    public String getApiAddress() {
        return apiAddress;
    }

    public void setApiAddress(String apiAddress) {
        this.apiAddress = apiAddress;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public List<ColumnInfoDto> getColumnInfoDtoList() {
        return columnInfoDtoList;
    }

    public void setColumnInfoDtoList(List<ColumnInfoDto> columnInfoDtoList) {
        this.columnInfoDtoList = columnInfoDtoList;
    }

    public List<OrderInfoDto> getOrderInfoDtoList() {
        return orderInfoDtoList;
    }

    public void setOrderInfoDtoList(List<OrderInfoDto> orderInfoDtoList) {
        this.orderInfoDtoList = orderInfoDtoList;
    }

    public List<TagDTO> getTagList() {
        return tagList;
    }

    public void setTagList(List<TagDTO> tagList) {
        this.tagList = tagList;
    }

    public DssSubscribeDTO getSubscribeDTO() {
        return subscribeDTO;
    }

    public void setSubscribeDTO(DssSubscribeDTO subscribeDTO) {
        this.subscribeDTO = subscribeDTO;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getReleaseTypeString() {
        return releaseTypeString;
    }

    public void setReleaseTypeString(String releaseTypeString) {
        this.releaseTypeString = releaseTypeString;
    }

    public String getTypeString() {
        return typeString;
    }

    public void setTypeString(String typeString) {
        this.typeString = typeString;
    }

    public String getStatusString() {
        return statusString;
    }

    public void setStatusString(String statusString) {
        this.statusString = statusString;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getTagName() {
        return tagName;
    }

    public void setTagName(String tagName) {
        this.tagName = tagName;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Long getViewCount() {
        return viewCount;
    }

    public void setViewCount(Long viewCount) {
        this.viewCount = viewCount;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "服务管理模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "服务管理";
        } else {
            return super.logTitle;
        }
    }

    @Override
    public PlatformConstant.LogType getLogType() {
        if (super.logType == null) {
            return PlatformConstant.LogType.module_operate;
        } else {
            return super.logType;
        }
    }

}
